2017-10-13 shell 练习-判断某个文件是否存在 shell练习 编写一个名为iffile程序,它执行时判断/bin目录下date文件是否存在? 编写一个名为greet的问候程序,它执行时能根据系统当前的时间向用户输出问候信息。设从半夜到中午为早晨,中午到下午六点为下午,下午六点到半夜为晚上。 1234567#!/bin/bashif [ -f /bin/date ] then echo "/bin/date file exist."else echo "/bin/date not exist."fi 或者 1234567891011#!/bin/bashh=`date +%H`if [ $h -ge 0 ] && [ $h -lt 12 ]then echo "Good morning."elif [ $h -ge 12 ] && [ $h -lt 18 ]then echo "Good afternoon."else echo "Good evening."fi < shell 练习-判断用户是否登录中 shell 练习-格式化输出数字串 >